﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;

namespace mOceanWindows
{

    public enum LogType
    {
        Error = 1,
        Warning = 2,
        Info = 3
    }

    public enum LogLevel
    {
        Disabled = 0,
        Error = 1,
        ErrorWarning = 2,
        All = 3
    }

    public abstract class Logger
   {

        public void WriteLine(object source, LogType logtype, String message, String parameter)
        {
            GCHandle gc = GCHandle.Alloc(source);
            IntPtr ptr = GCHandle.ToIntPtr(gc);
            gc.Free();

            string stub = DateTime.Now.ToString("dd-MM-yyyy HH:MM:ss ") +
                          Path.GetFileNameWithoutExtension(System.Windows.Forms.Application.ExecutablePath) + " :: AdSDK " +
                          source.ToString() + "(" + ptr.ToString() + ") ";
            switch (logtype)
            {
                case LogType.Info:
                    stub += "Info, ";
                    break;
                case LogType.Warning:
                    stub += "Warn, ";
                    break;
                case LogType.Error:
                    stub += "Error, ";
                    break;
            }
            stub += message;

            if (!String.IsNullOrEmpty(parameter)) stub += " | " + parameter;

            WriteOut( stub );
        }

        protected abstract void WriteOut(String str);
    }
}
